#ifndef SEATDETECTIONPARAMETER_H
#define SEATDETECTIONPARAMETER_H

#include <QDomDocument>
#include <QDomElement>
#include <QDomProcessingInstruction>
#include <QFile>
#include <QMap>
#include <QMessageBox>
#include <QVector3D>
#include "savelog.h"

typedef struct _tagCameraConfig
{
    QString name;
    QString MAC;
    QString IP;
    QStringList numbers;
} CAMERA;

typedef struct _tagSeatShowInfo
{
    QVector3D angle;
    QVector3D scale;
    QVector3D viewpos;
} SEATSHOWINFO;

class SeatDetectionParameter : public QObject
{
    Q_OBJECT
public:
    SeatDetectionParameter();
    ~SeatDetectionParameter();

public:
    SeatDetectionParameter& operator=(SeatDetectionParameter& obj);

private:
    // 相机采集图像的原始路径
    QString originalImagePath;
    // 程序处理图像的零时路径
    QString temporalImagePath;
    // 程序处理图像后生成的结果路劲（缺陷的txt表示）
    QString resultTxtPath;
    // Description文件路径
    QString descriptionFilePath;
    // Image File 文件类型(后缀)
    QString imageFileExtension;
    // 提供图像处理的服务器IP地址
    QString recognitionServerIp;
    // 提供图像处理的服务程序的Port号
    QString recognitionServerPort;
    // 控制服务器IP地址
    QString controlServerIp;
    // 控制服务器Port号
    QString controlServerPort;
    // 里面表示需要检查塌陷的位置
    QStringList collapseSurface;
    // 检查窗口子图像数量(总数，行数，列数）
    int8_t detectionTotalSubImageCount;
    int8_t detectionRowSubImageCount;
    int8_t detectionColumnSubImageCount;

    // 所有相机的配置信息
    int                     cameraCount;
    QList<CAMERA>           cameras;
    QMap<QString, int>      classes;
    QList<SEATSHOWINFO>     seatShowInfos;

public:
    int GetCameraCount() { return cameraCount; }
    void SetCameraCount(int count) { cameraCount = count; }
    QList<CAMERA> &GetCameras() { return cameras; }
    void SetCameras(QList<CAMERA> &cameras) { this->cameras = cameras; }
    QMap<QString, int> &GetClasses() { return classes; }
    void SetClasses(QMap<QString, int> &cs) { classes = cs; }

    QList<SEATSHOWINFO> &GetSeatShowInfos() { return seatShowInfos; }
    void SetSeatShowInfos(QList<SEATSHOWINFO> &seatShowInfos)
    {
        this->seatShowInfos = seatShowInfos;
    }

    QStringList GetCollapseSurface(){
        return collapseSurface;
    }

    void SetCollapseSurface(QStringList collapseSurface){
        this->collapseSurface = collapseSurface;
    }

public:

    const QString &GetOriginalImagePath() { return originalImagePath; }
    const QString &GetTemporalImagePath() { return temporalImagePath; }
    const QString &GetResultTxtPath() { return resultTxtPath; }
    const QString &GetRecognitionServerIp() { return recognitionServerIp; }
    const QString &GetRecognitionServerPort() { return recognitionServerPort; }
    const QString &GetControlServerIp() { return controlServerIp; }
    const QString &GetControlServerPort() { return controlServerPort; }
    int8_t GetDetectionTotalSubImageCount() { return detectionTotalSubImageCount; }
    int8_t GetDetectionRowSubImageCount() { return detectionRowSubImageCount; }
    int8_t GetDetectionColumnSubImageCount() { return detectionColumnSubImageCount; }

    void SetOriginalImagePath(QString value) { originalImagePath = value; }
    void SetTemporalImagePath(QString value) { temporalImagePath = value; }
    void SetResultTxtPath(QString value) { resultTxtPath = value; }
    void SetRecognitionServerIp(QString value) { recognitionServerIp = value; }
    void SetRecognitionServerPort(QString value) { recognitionServerPort = value; }
    void SetControlServerIp(QString value) { controlServerIp = value; }
    void SetControlServerPort(QString value) { controlServerPort = value; }
    void SetDetectionTotalSubImageCount(int8_t value) { detectionTotalSubImageCount = value; }
    void SetDetectionRowSubImageCount(int8_t value) { detectionRowSubImageCount = value; }
    void SetDetectionColumnSubImageCount(int8_t value) { detectionColumnSubImageCount = value; }

public:
    // 初始化所有的参数
    void InitParameter();
    //
    void ReadParameterFromXml(QString xmlFilePath);

    void WriteParameterToXml(QString xmlFilePath);

    void ConfigCameraToXml(QString xmlFilePath);

public:
    QString toString();
    QString getDescriptionFilePath() const;
    QString getImageFileExtension() const;
    void SetDescriptionFilePath(QString descriptionFilePath);
    void SetImageFileExtension(QString imageFileExtension);
};

#endif // SEATDETECTIONPARAMETER_H
